package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.event.NoticeEvent;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.model.impl.NoticeModel;
import com.clas.liu.myapplication.presenter.i.INoticePresenter;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;
import com.clas.liu.myapplication.view.activity.impl.NoticeActivity;

/**
 * Created by liu on 2019/5/20.
 */

public class NoticePresenter extends BasePresenter<NoticeActivity, NoticeModel> implements INoticePresenter {

    public NoticePresenter(NoticeActivity view) {
        super(view);
    }

    @Override
    public void getNotices(int page_no, int page_size) {
        mModel.getNotices(page_no, page_size);
    }

    @Override
    protected NoticeModel getModel(Handler handler) {
        return new NoticeModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case NoticeEvent.GET_NOTICE_OK:
                mView.getNoticeReturn(((NoticeEvent)msg.obj).getNoticeRoot().getData());
                break;
            case NoticeEvent.GET_NOTICE_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
        }
    }
}
